#ifndef _KFIFO_H
#define _KFIFO_H


//声明 一个 结构体 kfifo

struct KFIFO
{
  unsigned char *buffer;    /* the buffer holding the data */
  unsigned int size;            /* the size of the allocated buffer */
  unsigned int in;                /* data is added at offset (in % size) */
  unsigned int out;                /* data is extracted from off. (out % size) */
  unsigned char is_full;
};

struct KFIFO *kfifo_alloc(unsigned int size);
void kfifo_free(struct KFIFO *fifo);
void kfifo_init(struct KFIFO *fifo);
unsigned int kfifo_put(struct KFIFO *fifo, unsigned char *buffer, unsigned int len);
unsigned int kfifo_get(struct KFIFO *fifo, unsigned char *buffer, unsigned int len);

unsigned int kfifo_len(struct KFIFO *fifo);
unsigned int kfifo_is_empty(struct KFIFO *fifo);
unsigned int kfifo_is_full(struct KFIFO *fifo);
char kfifo_peek(struct KFIFO *fifo, unsigned int idx);
unsigned int kfifo_out_peek(struct KFIFO *fifo, unsigned char *buffer, unsigned int len);
void kfifo_throw(struct KFIFO *fifo, unsigned int len);

#endif
